package org.example.strategypatterndemo.Strategy;

import org.example.strategypatterndemo.module1.service.PromotionStrategy;
import org.example.strategypatterndemo.module1.service.impl.DiscountStrategy;
import org.example.strategypatterndemo.module1.service.impl.FullReduceStrategy;
import org.example.strategypatterndemo.module1.service.impl.GiftStrategy;
import org.springframework.stereotype.Component;

@Component
public class PromotionStrategyFactory {

    public PromotionStrategy createStrategy(String strategyType) {
        switch (strategyType.toUpperCase()) {
            case "DISCOUNT":
                return new DiscountStrategy();
            case "FULL_REDUCE":
                return new FullReduceStrategy();
            case "GIFT":
                return new GiftStrategy();
            default:
                throw new IllegalArgumentException("未知策略类型: " + strategyType);
        }
    }
}
